﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Data.Entity;
using GDoc.Domain;
using GDoc.Data.Sql;

namespace GDoc.Web
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            // Browse
            routes.MapRoute("BrowseFiles", "Files/Browse/{*path}", new { controller = "Files", action = "Browse" });
            // Get files
            routes.MapRoute("GetFiles", "Files/GetFiles/{*path}", new { controller = "Files", action = "GetFiles" });
            // Get file
            routes.MapRoute("GetFile", "Files/GetFile/{*path}", new { controller = "Files", action = "GetFile" });
            // Get file
            routes.MapRoute("RemoveFile", "Files/Remove/{*path}", new { controller = "Files", action = "Remove" });
            // Upload files
            routes.MapRoute("UploadFiles", "Files/Upload/{*path}", new { controller = "Files", action = "Upload" });
            // Create folder
            routes.MapRoute("CreateFolder", "Files/CreateFolder", new { controller = "Files", action = "CreateFolder" });

            // Account > Create Group
            routes.MapRoute("AccountGroup", "Account/Group/{id}", new { controller = "Account", action = "Group" });
            // Account > Create Group
            routes.MapRoute("AccountUser", "Account/User/{id}", new { controller = "Account", action = "User" });
            // Account > Create Group
            routes.MapRoute("AddGroup", "Account/AddGroup", new { controller = "Account", action = "AddGroup" });

            // Default
            routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            //Database.SetInitializer(new SeedData());
        }
    }
}